package bootstrap

import (
	"context"
	"database/sql"
	"github.com/kataras/iris/v12"
	"iris_product/backend/web/controllers"
)

// key 为路由,值为控制器对象
var controllerList =  map[string]controllers.IBController{
	"/order":new(controllers.OrderController),
}

type InitApp struct {
	IrisApp *iris.Application
	Ctx context.Context
	Db *sql.DB
}

func (i *InitApp) Bootstrap() {
	// 循环注册 controller
	for routePath, controllerObj := range controllerList {
		// 初始化控制器和路由
		controllerObj.InitController(i.IrisApp,i.Db,routePath)
		controllerObj.RegisterService()
		controllerObj.RegisterController(controllerObj)

	}
}
